//
//  TouchSurfaceView.m
//  midiApp
//
//  Created by Laurent Novac on 17.02.11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TouchSurfaceView.h"
#import "Position.h"

@implementation TouchSurfaceView
@synthesize tPosition;

/*--------------------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------INIT--------------------------------------------------------------------------------------------------*/

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code.
		tPosition=[[Position alloc]init];
    }
    return self;
}

/*--------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------DRAWING ROUTINE-----------------------------------------------------------------------------------*/

- (void)drawRect:(CGRect)rect {
	// Drawing code.
	CGContextRef context = UIGraphicsGetCurrentContext();
	
	CGContextSetLineWidth(context, 2.0);
	
	CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
	
	CGRect rectangle = CGRectMake([tPosition pos].x,[tPosition pos].y,50,50); //position is updated by controller based on the finger pos
	
	CGContextAddEllipseInRect(context, rectangle);
	
	CGContextStrokePath(context);	
}

/*--------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------MEMORY MANAGEMENT---------------------------------------------------------------------------------*/

- (void)dealloc {
	[tPosition release];
    [super dealloc];
}


@end
